<?php /* Smarty version 2.6.26, created on 2018-07-25 15:35:11
         compiled from E:%5CWWW%5C40.125.208.171%5Cvweb/member%5Ctemplates/xuq/index.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'import', 'E:\\WWW\\40.125.208.171\\vweb/member\\templates/xuq/index.html', 1, false),array('function', 'uqcms', 'E:\\WWW\\40.125.208.171\\vweb/member\\templates/xuq/index.html', 22, false),)), $this); ?>
<?php echo $this->_plugins['function']['import'][0][0]->import(array('file' => "index/header.html",'title' => "收货地址"), $this);?>

<style type="text/css"> 
.addtab{ width:1880px; border-bottom:none; padding:0 0 12px 0; float:left; }
.addtab a{ border:1px solid #ddd; padding:7px 25px; font-size:12px; border-radius:1px; font-weight:100; background:#f8f8f8; color:#333; float:left; }
a.edit_font{ margin:0 12px 0 0; float:left; }
</style> 
<div class="lbox">
	<div class="addtab"> 
		<a href="javascript:;" onClick="edit_address('添加需求','member.php?m=xuq&a=edit')" id="add_xuq">添加需求</a>
	</div>
	<table class="ltable">
		<thead>
			<tr>
				<th width="70">姓名</th>
				<th width="110">电话</th>
				<th>地址</th>
				<th width="100">操作</td>
				<th width="80">默认</th>
			</tr>
		</thead> 
		<tbody>
		<?php echo $this->_plugins['function']['uqcms'][0][0]->load_module(array('m' => 'address','v' => 'add','c' => 'get_all'), $this);?>
 	
		<?php if ($this->_tpl_vars['add']): ?> 	
			<?php $_from = $this->_tpl_vars['add']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['i']):
?>		
			<tr>
				<td><?php echo $this->_tpl_vars['i']['name']; ?>
</td>
				<td><?php echo $this->_tpl_vars['i']['mobile']; ?>
</td>
				<td><?php echo $this->_tpl_vars['i']['area']; ?>
, <?php echo $this->_tpl_vars['i']['address']; ?>
 </td> 
				<td>
					<a href="javascript:;" class="edit_font" onClick="edit_address('修改地址','member.php?m=address&a=edit&id=<?php echo $this->_tpl_vars['i']['id']; ?>
')">编辑</a>
					<a href="javascript:;" class="addr_del" data-id="<?php echo $this->_tpl_vars['i']['id']; ?>
">删除</a>
				</td>
				<td>
					<div class="dft_box">
						<?php if ($this->_tpl_vars['i']['is_default'] == '1'): ?>
							<a style="color:#FF0000;">默认</a>
						<?php else: ?>
							<a href="javascript:;" class="set_default" data-id="<?php echo $this->_tpl_vars['i']['id']; ?>
">设为默认</a>
						<?php endif; ?>
					</div> 
				</td> 
			</tr>
			<?php endforeach; endif; unset($_from); ?>
		<?php else: ?>
			<tr><td colspan="5" class="btm"><div class="nomsg"><i></i><span>您还没添加送货地址~</span></div></td></tr> 
		<?php endif; ?>
		</tbody> 
	</table>
</div> 	 
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "index/footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?> 
<script type="text/javascript"> 
function edit_address(name,url){ 
	ajax_dialog(name,url, 1880); 
} 
// 设为默认 
$(document).on("click",".set_default",function(){ 
	$this = $(this);
	var id = $(this).attr('data-id');
	$.post('member.php?m=address&a=set_default',{id:id},function(result){
		var data = jQuery.parseJSON(result); 
		if(data.error == '0'){
			$.alert('设置成功', function(){
				location.reload();
			});
		}else{
			$.alert(data.msg);
		}
	});
});
// 删除地址
$(document).on("click",".addr_del",function(){ 
	if (!confirm("确认要删除？")) { 
		if(window.event){
			window.event.returnValue = false;
		}else{  
			event.preventDefault();	//for firefox
		}
	}else{
		$this = $(this);
		var id = $this.attr('data-id');
		$.post('member.php?m=address&a=del',{id:id},function(result){
			var data = jQuery.parseJSON(result);  
			if(data.error == '0'){ 
				$.alert('删除成功', function(){
					location.reload();
				});
			}else{
				alert(data.msg);
			}
		});	
	}
});
</script>